package com.xy.annotaion.handler.kotlin.pdf

import com.lowagie.text.Document
import com.lowagie.text.DocumentException
import com.lowagie.text.Paragraph
import com.lowagie.text.pdf.PdfWriter
import java.io.FileOutputStream
import java.io.IOException


fun main() {
    println("Hello World")

    // step 1: creation of a document-object

    // step 1: creation of a document-object
    val document = Document()
    try {
        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file
        PdfWriter.getInstance(
            document,
            FileOutputStream("HelloWorld.pdf")
        )

        // step 3: we open the document
        document.open()
        // step 4: we add a paragraph to the document
        document.add(Paragraph("Hello World"))
    } catch (de: DocumentException) {
        System.err.println(de.message)
    } catch (ioe: IOException) {
        System.err.println(ioe.message)
    }

    // step 5: we close the document

    // step 5: we close the document
    document.close()
}